import {BrowserWindow} from 'electron'
export default async(options,routerPath) => {
    options.webPreferences = {
         // Use pluginOptions.nodeIntegration, leave this alone
        // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
        nodeIntegration: true,
        contextIsolation: false,
        enableRemoteModule: true,
    }
    // Create the browser window.
    const win = new BrowserWindow(options);
    routerPath = routerPath?`#/${routerPath}`:'';
    if (process.env.WEBPACK_DEV_SERVER_URL) {
        // Load the url of the dev server if in development mode
        await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL + routerPath)
        // if (!process.env.IS_TEST) win.webContents.openDevTools()
    } else {
        createProtocol('app')
        // Load the index.html when not in development
        win.loadURL('app://./index.html' + routerPath)
    }
    return win;
}
